from django.http import Http404
from django.http import HttpResponse, QueryDict
from django.template import TemplateDoesNotExist
from django.views.generic.simple import direct_to_template

import sys
from TileCache.Client import seed
from piri.tilecache import TileCacheFacade
   
def gen(request):
    tc = TileCacheFacade()
    tc.seed((0, 1))

    try:
        return direct_to_template(request, template="done.html")
    except TemplateDoesNotExist:
        raise Http404()

def tilecache(request,x=None):
    params = request.REQUEST
    tc = TileCacheFacade()
    format, image = tc.dispatch(params)
    return HttpResponse(image, mimetype=format)
